package main

import (
	"fmt"
	"time"
)

//for循环
func main() {
	start := time.Now().Unix()
	soure := []int{0, 1, 0, 3, 12}
	result := moveZeroes(soure)
	end := time.Now().Unix()
	fmt.Println("输出结果", result, "计算耗时:", end-start)
}

func moveZeroes(nums []int) [5]int {
	fmt.Println(len(nums))
	soure := [5]int{0, 1, 0, 3, 12}
	var result [5]int
	resultIndex := 0
	for i := range soure {
		index := soure[i]
		//fmt.Println("循环次数",i,"数组值",index)
		if index != 0 {
			result[resultIndex] = index
			resultIndex++
		}
	}
	return result
}
